/* eslint-disable react/prop-types */

import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';

import WorksScrollList from 'components/WorksScrollList.js';

import * as workAction from '../../WorkAction';

@connect(null, buildActionDispatcher)
export default class RecommendedWorksComponent extends React.Component {
  constructor(props) {
    super(props);
    this.loadPage = this.loadPage.bind(this);
  }

  loadPage(pageId, limit) {
    const { workAction } = this.props;
    return workAction.getRecommendedWorkList(pageId, limit);
  }

  render() {
    return (
      <div id="work-featured">
        <div className="header">
          <span className="title">推荐</span>
        </div>
        <WorksScrollList loadPage={this.loadPage} {...this.props} />
      </div>
    );
  }
}

function buildActionDispatcher(dispatch) {
  return {
    workAction: bindActionCreators(workAction, dispatch),
  };
}
